var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function a() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((a.prototype = i.prototype), new a()));
      };
    })(),
  AXRisingStarView = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        e.btn_shengxingtai_shuoming.on(
          Laya.Event.CLICK,
          e,
          e.onLookShengXingShuoMing
        ),
        e.btn_shengxing_back.on(Laya.Event.CLICK, e, e.onPreSquareBack),
        e.btn_zhufujiang_sel.on(Laya.Event.CLICK, e, e.onSelFujiangAction),
        e.btn_congfujiang_sel.on(Laya.Event.CLICK, e, e.onSelFujiangAction),
        WebSocketService.addListener({
          caller: e,
          code: 1129,
          method: e.onLoadSubStarData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1109,
          method: e.onLoadSubStarData1,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1124,
          method: e.onLoadSureShengXingData,
        }),
        e.btn_star_shengxing.on(Laya.Event.CLICK, e, e.onDidClickSureStar),
        e
      );
    }
    return (
      __extends(e, t),
      (e.showRisingStarView = function () {
        return (
          null == this.risingStarVC && (this.risingStarVC = new e()),
          (this.risingStarVC.btn_congfujiang_sel.visible = !1),
          (this.risingStarVC.mainStarObj = {}),
          (this.risingStarVC.subStarObj = {}),
          this.risingStarVC.initData(),
          (this.risingStarVC.btn_star_shengxing.gray = !0),
          (this.risingStarVC.btn_star_shengxing.disabled = !0),
          (this.risingStarVC.btn_zhufujiang_sel.label = "选择"),
          this.risingStarVC
        );
      }),
      (e.prototype.onLookShengXingShuoMing = function () {
        var t = CaslnoRulesView.showCaslRuleView("shengxingshuoming");
        (t.y = 40), (t.height = 570), Laya.stage.addChild(t);
      }),
      (e.prototype.onPreSquareBack = function () {
        this.removeSelf();
      }),
      (e.prototype.onSelFujiangAction = function (t) {
        if ("Item_main" == t.target.name) {
          e = { title: "主副将", id: this.mainStarObj.id };
          AXSelStarListDialog.showSelStarDialog(
            e,
            this,
            this.onSureMainStarData
          );
        } else if ("Item_sub" == t.target.name) {
          var e = {
            title: "从副将",
            id: this.mainStarObj.id,
            star: this.mainStarObj.star,
          };
          AXSelStarListDialog.showSelStarDialog(
            e,
            this,
            this.onSureSubStarData
          );
        }
      }),
      (e.prototype.onSureMainStarData = function (t) {
        (this.mainStarObj = t),
          WebSocketService.send({ c: 1129, d: { id: t.id } }),
          WebSocketService.send({ c: 1109, d: { id: t.id } }),
          (this.refreshItem = "主副将"),
          (this.btn_zhufujiang_sel.label = "更换"),
          (this.btn_congfujiang_sel.visible = !0),
          this.subStarObj.id &&
            t.id != this.subStarObj.id &&
            this.initsubStar();
      }),
      (e.prototype.onSureSubStarData = function (t) {
        (this.subStarObj = t),
          (this.refreshItem = "从副将"),
          (this.btn_congfujiang_sel.label = "更换"),
          (this.btn_star_shengxing.visible = !0),
          WebSocketService.send({ c: 1129, d: { id: t.id } }),
          WebSocketService.send({ c: 1109, d: { id: t.id } }),
          (this.btn_star_shengxing.gray = !1),
          (this.btn_star_shengxing.disabled = !1);
      }),
      (e.prototype.onLoadSubStarData = function (t) {
        if (0 == t.code) {
          var e = t.data;
          if ("主副将" == this.refreshItem) {
            this.initData(),
              (this.label_star_name.text = e.name),
              (this.label_numStar.text =
                Utils.dealTransAndLvl(e.roleType, e.lvl) +
                "(" +
                e.star +
                "星)"),
              (this.label_roleStyle.text = this.dealRoleType(e.roleType)),
              (this.label_star_chengzhang.text = "成长值：" + e.czl),
              (this.sValue = this.dealXingNumber(e.star)),
              (this.label_star_qixue.text = "气血初值：" + e.maxHp),
              (this.label_star_jingli.text = "精力初值：" + e.maxMp),
              (this.label_star_gongji.text = "攻击初值：" + e.ap),
              (this.label_star_minjie.text = "敏捷初值：" + e.sp);
            for (var i = e.skillList, a = 0; a < i.length; a++)
              if (0 == a) {
                s = i[a];
                this.label_star_item1.text =
                  s.name + this.dealGradeOrHuaString(s);
              } else if (1 == a) {
                s = i[a];
                this.label_star_item2.text =
                  s.name + this.dealGradeOrHuaString(s);
              } else if (2 == a) {
                s = i[a];
                this.label_star_item3.text =
                  s.name + this.dealGradeOrHuaString(s);
              }
          } else {
            (this.label_star_name1.text = e.name),
              (this.label_numStar1.text = e.lvl + "级 (" + e.star + "星)"),
              (this.label_roleStyle1.text = this.dealRoleType(e.roleType)),
              (this.label_star_chengzhang1.text = "成长值：" + e.czl),
              (this.label_star_qixue1.text = "气血初值：" + e.hp),
              (this.label_star_jingli1.text = "精力初值：" + e.mp),
              (this.label_star_gongji1.text = "攻击初值：" + e.ap),
              (this.label_star_minjie1.text = "敏捷初值：" + e.sp),
              (this.label_chengzhangzhi_rise.text = this.sValue);
            for (var i = e.skillList, a = 0; a < i.length; a++)
              if (0 == a) {
                s = i[a];
                this.label_star1_item1.text =
                  s.name + this.dealGradeOrHuaString(s);
              } else if (1 == a) {
                s = i[a];
                this.label_star1_item2.text =
                  s.name + this.dealGradeOrHuaString(s);
              } else if (2 == a) {
                var s = i[a];
                this.label_star1_item3.text =
                  s.name + this.dealGradeOrHuaString(s);
              }
          }
        }
      }),
      (e.prototype.dealGradeOrHuaString = function (t) {
        return t.hua >= 1
          ? "\n化境Lv" + t.grade + "\n(" + t.useCount + "熟)"
          : "\n" + t.grade + "级\n(" + t.useCount + "熟)";
      }),
      (e.prototype.onLoadSubStarData1 = function (t) {
        if (0 == t.code) {
          var e = t.data,
            i = this.bijiaodaxiao(e),
            a = this.stringForName(i[0].key) + i[0].value,
            s = this.stringForName(i[1].key) + i[1].value,
            r = this.stringForName(i[2].key) + i[2].value;
          "主副将" == this.refreshItem
            ? ((this.label_star_wu.text = a),
              (this.label_star_feng.text = s),
              (this.label_star_wei.text = r))
            : ((this.label_star_wu1.text = a),
              (this.label_star_feng1.text = s),
              (this.label_star_wei1.text = r));
        }
      }),
      (e.prototype.bijiaodaxiao = function (t) {
        var e = [];
        for (var i in t)
          if ("k" == i.charAt(0)) {
            var a = { key: i, value: t[i] };
            e.push(a);
          }
        for (var s = 0; s < 3; s++)
          for (var r = s + 1; r < e.length; r++) {
            var n = void 0;
            e[r].value > e[s].value && ((n = e[s]), (e[s] = e[r]), (e[r] = n));
          }
        return e;
      }),
      (e.prototype.stringForName = function (t) {
        var e;
        return (
          "kd" == t
            ? (e = "抗毒")
            : "kfjn" == t
            ? (e = "抗封")
            : "kfs" == t
            ? (e = "抗风")
            : "kll" == t
            ? (e = "抗雷")
            : "krl" == t
            ? (e = "抗乱")
            : "kwk" == t
            ? (e = "抗围")
            : "kwldj" == t
            ? (e = "抗物")
            : "kxhp" == t
            ? (e = "抗吸")
            : "kyh" == t && (e = "抗火"),
          e
        );
      }),
      (e.prototype.dealRoleType = function (t) {
        return Utils.transform(t % 10, "roleType");
      }),
      (e.prototype.initData = function () {
        (this.label_star_name.text = ""),
          (this.label_numStar.text = ""),
          (this.label_roleStyle.text = ""),
          (this.label_star_wu.text = ""),
          (this.label_star_feng.text = ""),
          (this.label_star_wei.text = ""),
          (this.label_star_chengzhang.text = ""),
          (this.label_star_qixue.text = ""),
          (this.label_star_jingli.text = ""),
          (this.label_star_gongji.text = ""),
          (this.label_star_minjie.text = ""),
          (this.label_chengzhangzhi_rise.text = ""),
          (this.label_star_item1.text = ""),
          (this.label_star_item2.text = ""),
          (this.label_star_item3.text = ""),
          this.initsubStar();
      }),
      (e.prototype.initsubStar = function () {
        (this.label_star_name1.text = ""),
          (this.label_numStar1.text = ""),
          (this.label_roleStyle1.text = ""),
          (this.label_star_wu1.text = ""),
          (this.label_star_feng1.text = ""),
          (this.label_star_wei1.text = ""),
          (this.label_star_chengzhang1.text = ""),
          (this.label_star_qixue1.text = ""),
          (this.label_star_jingli1.text = ""),
          (this.label_star_gongji1.text = ""),
          (this.label_star_minjie1.text = ""),
          (this.label_star1_item1.text = ""),
          (this.label_star1_item2.text = ""),
          (this.label_star1_item3.text = "");
      }),
      (e.prototype.dealXingNumber = function (t) {
        var e = "";
        return (
          "0" == t
            ? (e = " +0.01")
            : "1" == t
            ? (e = " +0.02")
            : "2" == t
            ? (e = " +0.03")
            : "3" == t
            ? (e = " +0.04")
            : "4" == t
            ? (e = " +0.05")
            : "5" == t && (e = " +0.06"),
          e
        );
      }),
      (e.prototype.onDidClickSureStar = function () {
        var t = "",
          e = this.mainStarObj.star;
        1 == this.mainStarObj.s
          ? 0 == e
            ? (t = "1000金币")
            : 1 == e
            ? (t = "2000金币")
            : 2 == e
            ? (t = "3000金币")
            : 3 == e
            ? (t = "5000金币")
            : 4 == e && (t = "1W金币")
          : 2 == this.mainStarObj.s
          ? 0 == e
            ? (t = "500金币")
            : 1 == e
            ? (t = "1000金币")
            : 2 == e
            ? (t = "2000金币")
            : 3 == e
            ? (t = "3000金币")
            : 4 == e && (t = "5000金币")
          : 3 == this.mainStarObj.s
          ? 0 == e
            ? (t = "1W金币")
            : 1 == e
            ? (t = "2W金币")
            : 2 == e
            ? (t = "5W金币")
            : 3 == e
            ? (t = "10W金币")
            : 4 == e && (t = "20W金币")
          : 4 == this.mainStarObj.s &&
            (0 == e
              ? (t = "0银币")
              : 1 == e
              ? (t = "1W银币")
              : 2 == e
              ? (t = "2W银币")
              : 3 == e
              ? (t = "5W银币")
              : 4 == e && (t = "10W银币")),
          NormalDialog.showNormalDialog(
            "确定消耗" + t + "升至" + (e + 1) + "星",
            this,
            this.onSureAction
          );
      }),
      (e.prototype.onSureAction = function () {
        var t = this.mainStarObj.id,
          e = this.subStarObj.id;
        WebSocketService.send({ c: 1124, d: { id1: t, id2: e } });
      }),
      (e.prototype.onLoadSureShengXingData = function (t) {
        0 == t.code &&
          (this.initsubStar(),
          (this.subStarObj = {}),
          (this.refreshItem = "主副将"),
          WebSocketService.send({ c: 1129, d: { id: this.mainStarObj.id } }),
          WebSocketService.send({ c: 1109, d: { id: this.mainStarObj.id } }),
          (this.btn_star_shengxing.gray = !0),
          (this.btn_star_shengxing.disabled = !0),
          (this.btn_congfujiang_sel.label = "选择")),
          ToastView.toastView(t.msg);
      }),
      e
    );
  })(ui.SquareController.AXRisingStarViewUI);
